/**
 * 左侧菜单栏
 */
SidebarEvent = {
	'BindEvent' : function() {
		$('#logout').bind('click', function() {
			var user_id = $('#user_id').val();
			AdminService.Logout(user_id);
			window.location.href = ServerConfig.AdminConfig.login_page;
		});
		
	}
};

$(document).ready(function() {
	/*SidebarEvent.BindEvent();
	SidebarEvent.Init();*/
});

CommonPage = {
	'BindProvince' : function() {
		var result = CommonService.getAllProvince();
		if (result.IsSuccess == 1) {
			$('#ssl_province').html('');
			var html = '';
			for ( var index in result.Result) {
				var province_en = result.Result[index];
				html += '<option text="' + province_en.province_name
						+ '" value="' + province_en.province_id + '">';
				html += province_en.province_name;
				html += '</option>';
			}
			$('#ssl_province').append(html);
			$('#ssl_province').trigger('change');
		} else {
			alert(result.ErrorMsg);
		}
	},
	'BindCity' : function(province_id) {
		var result = CommonService.getCityListByProvinceId(province_id);
		if (result.IsSuccess == 1) {
			$('#ssl_city').html('');
			var html = '';
			for ( var index in result.Result) {
				var city_en = result.Result[index];
				html += '<option text="' + city_en.city_name + '" value="'
						+ city_en.city_id + '">';
				html += city_en.city_name;
				html += '</option>';
			}
			$('#ssl_city').append(html);
			$('#ssl_city').trigger('change');
		} else {
			alert(result.ErrorMsg);
		}
	},
	'BindDistrict' : function(city_id) {
		var result = CommonService.getDistrictListByCityId(city_id);
		if (result.IsSuccess == 1) {
			$('#ssl_district').html('');
			var html = '';
			for ( var index in result.Result) {
				var district_en = result.Result[index];
				html += '<option text="' + district_en.district_name
						+ '" value="' + district_en.district_id + '">';
				html += district_en.district_name;
				html += '</option>';
			}
			$('#ssl_district').append(html);
			$('#ssl_district').trigger('change');
		} else {
			alert(result.ErrorMsg);
		}
	},'convertNull' : function (str) { //共通转空操作
        if (str) return str;
        return "";
    },'InitRegion' : function(city_id) {
		CommonPage.BindProvince();
		CommonPage.BindCity($('#ssl_province').val());
		CommonPage.BindDistrict($('#ssl_city').val());

		$('#ssl_province').bind('change', function() {
			CommonPage.BindCity($('#ssl_province').val());
		});

		$('#ssl_city').bind('change', function() {
			CommonPage.BindDistrict($('#ssl_city').val());
		});
	},
	'BindEvent' : function() {
		$('#logout').bind('click', function() {
			var user_id = $('#user_id').val();
			AdminService.Logout(user_id);
			window.location.href = ServerConfig.AdminConfig.login_page;
		});
		$('#shouPage').bind('click', function(){
			window.location.href = ServerConfig.AdminConfig.jump_page;
		});
	}
};

$(document).ready(function() {
	CommonPage.BindEvent();
	CommonPage.InitRegion();
});
